<?php

namespace app\webapi\vms\validate;

use app\webapi\common\BaseValidate;

/**
 * @链接验证类
 */
class LinkValidate extends BaseValidate
{
    //验证规则
    protected $rule = [
        'page_no' => 'require|number',
        'page_size' => 'require|number',
        'type' => 'require|in:1,2',
        'name' => 'length:0,128',
        'url' => 'url',
        'sort' => 'number',
        'ids' => 'length:1,128',
        'is_show' => 'in:0,1',
    ];

    //验证消息
    protected $message = [
        'page_no.require' => '页码必填',
        'page_no.number' => '页码参数必须是整数类型',
        'page_size.require' => '每页显示条目数必填',
        'page_size.number' => '每页显示条目数必须是整数类型',
        'name.length' => '名称长度为0-128个字符',
        'type.require' => '类型必填',
        'type.in' => '类型可选值为1,2',
        'url.url' => '链接地址不是有效的地址',
        'sort.number' => '权重值必须是整数类型',
        'ids.length' => 'ids长度限制为128个字符',
        'is_show.in' => '是否显示可选值为0,1'
    ];

    //验证场景
    protected $scene = [
        'getPaginateList' => ['page_no', 'page_size'],
        'edit' => ['name', 'url', 'type', 'sort', 'content', 'is_show'],
        'getInfo' => ['id'],
        'delete' => ['ids'],
    ];

}